//
//  HDCFcommenQuestionVc.m
//  HaoDeCaiFu
//
//  Created by 郑开宏 on 2017/11/22.
//  Copyright © 2017年 郑开宏. All rights reserved.
//

#import "HDCFcommenQuestionVc.h"
#import <WebKit/WebKit.h>

@interface HDCFcommenQuestionVc ()<WKUIDelegate, WKNavigationDelegate>

@property (nonatomic, weak) WKWebView *webView;

@end

@implementation HDCFcommenQuestionVc

- (void)setVcTitle:(NSString *)vcTitle{
    _vcTitle = vcTitle;
}

- (void)setTypeInteger:(NSInteger)typeInteger{
    _typeInteger = typeInteger;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    if (_typeInteger) {
        if (_typeInteger == 1) {
            [self.navigationItem setTitle:@"投资人权益须知"];
        }else{
            [self.navigationItem setTitle:@"奕丰金融平台服务协议"];
        }
    }else{
        [self.navigationItem setTitle:@"常见问题"];
    }
    
    [SVProgressHUD show];
    CGRect rect = CGRectMake(0, 20, self.view.frame.size.width, self.view.frame.size.height - 49);
    WKWebView *webview = [[WKWebView alloc] initWithFrame:rect];
    webview.navigationDelegate = self;
    if (_typeInteger) {
        if (_typeInteger == 1) {
            NSString *path = [[NSBundle mainBundle] pathForResource:@"xy_qy" ofType:@"html"];
            NSURL *url = [NSURL fileURLWithPath:path];
            [webview loadRequest:[NSURLRequest requestWithURL:url]];
        }else{
            NSString *path = [[NSBundle mainBundle] pathForResource:@"xy_fw" ofType:@"html"];
            NSURL *url = [NSURL fileURLWithPath:path];
            [webview loadRequest:[NSURLRequest requestWithURL:url]];
        }
    }else{
        [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://jx.chinahonden.xyz:15504/file/app_help.aspx"]]];
    }
    
    [self.view addSubview:webview];
    _webView = webview;
}

- (void)initData{
    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://jx.chinahonden.xyz:15504/file/app_help.aspx"]]];
}

-(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
    
}

-(void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation{
    
}

-(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
    [SVProgressHUD dismiss];
    
}

- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation
{
    [SVProgressHUD dismiss];
    [self initData];
}

@end
